<<<<<<< HEAD
package com.hsx.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ServletDemo5 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        InputStream is = this.getServletContext().getResourceAsStream("/WEB-INF/classes/db.properties");
//        Properties prop = new Properties();
//        prop.load(is);
//        String username = prop.getProperty("username");
//        resp.getWriter().print(username);

        InputStream is = this.getServletContext().getResourceAsStream("/WEB-INF/classes/com/hsx/servlet/db.properties");
        Properties prop = new Properties();
        prop.load(is);
        String pwd = prop.getProperty("password");
        resp.getWriter().print(pwd);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
=======
package com.hsx.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ServletDemo5 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        InputStream is = this.getServletContext().getResourceAsStream("/WEB-INF/classes/db.properties");
//        Properties prop = new Properties();
//        prop.load(is);
//        String username = prop.getProperty("username");
//        resp.getWriter().print(username);

        InputStream is = this.getServletContext().getResourceAsStream("/WEB-INF/classes/com/hsx/servlet/db.properties");
        Properties prop = new Properties();
        prop.load(is);
        String pwd = prop.getProperty("password");
        resp.getWriter().print(pwd);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
>>>>>>> 0955e43271ec003176a75da3f24c6d9c0071fe9b
